package com.renke.server;

import lombok.extern.slf4j.Slf4j;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.ServerSocket;
import java.net.Socket;

/**
 * @Description
 * @Auther Z.R.K
 * @Date 2020/12/7 14:40
 **/
@Slf4j
public class JavaBIOServer {

    public static void startBIOServer(Integer port, BaseThread run){
        try {
            ServerSocket serverSocket = new ServerSocket(port);
            log.info("start BIO Server {}", port);
            while (true) {
                Socket client = serverSocket.accept();
                log.info("client in port {}", client.getPort());
                run.setSocket(client);
                new Thread(run).start();
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }



}
